package com.evil.kingdom.pojo.entity.tactics;

import com.evil.kingdom.pojo.entity.action.AbstractPosition;
import com.evil.common.mongo.entity.SingleName;
import com.evil.kingdom.pojo.enums.PhalanxLayoutEnum;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;

/**
 * 战术
 *
 * @author liyang
 * @date 2024-05-17 17:01
 */
@Getter
@Setter
@Document
public class Tactics implements SingleName {

    /**
     * 战术名称
     */
    @Id
    @NotBlank(message = "名称不能为空")
    private String name;

    /**
     * 方阵表
     */
    private Phalanxs phalanxs;

    @Override
    public String getEntityName() {
        return "战术";
    }

    /**
     * 方阵表
     */
    @Getter
    @Setter
    public static class Phalanxs extends HashMap<PhalanxLayoutEnum, Phalanx> {
    }

    /**
     * 方阵端点表
     */
    @Getter
    @Setter
    public static class Phalanx extends ArrayList<AbstractPosition> {

        public Phalanx() {
        }

        public Phalanx(AbstractPosition...positions) {
            if (null != positions) {
                Collections.addAll(this, positions);
            }
        }

        public Phalanx(Collection<AbstractPosition> positions) {
            if (null != positions) {
                this.addAll(positions);
            }
        }
    }
}
